// __PUBLIC__/js/page/admin/circle/addcircle
require(['../../common'], function() {
  require(['circle.addcirclemessage'])
})

define('circle.addcirclemessage', [
    'jquery',
    'css!ke/themes/default/default.css',
    'ke/kindeditor',
    'ke/lang/zh_CN',
    'jqp/validate'
  ], function($) {
    'use strict';

    var langType = document.documentElement.lang || 'zh-CN'
      var langMap = {
        'zh-CN': 'zh_CN',
        'zh-TW': 'zh_TW',
        'en-US': 'en'
      }
    var editor = KindEditor.editor({
      allowFileManager: true,
      langType: langMap[langType],
      uploadJson: APP + "?app=admin&m=Circle&a=uploadUpyun"
    })
    KindEditor.loadScript(editor.langPath + editor.langType + '.js?ver=' + encodeURIComponent(KindEditor.VERSION))
    

  KindEditor('#J_selectPic').click(function() {
    editor.loadPlugin('multiimage', function() {
      editor.plugin.multiImageDialog({
        clickFn: function(urlList) {
          KindEditor.each(urlList, function(i, data) {
            var html = ''
            html += '<input type="text" name="imageurl[]" value="' + data.url + '" class="input-text">&nbsp;&nbsp;<br/>'
            $('#J_imageUpload').append(html)
          });
          editor.hideDialog();
        }
      });
    });
  });    

  $('#J_form').validate({
    classPlace: '.kv',
    errorPlace: '.kv-error',
    errors: {
      content: {
        required: '请填写播报内容',
      },
    }
  })
})
